{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 在重复数组中寻找唯一的元素\n",
    "\n",
    "[![Author](https://img.shields.io/badge/Author-%40mjd507-important?style=social&logo=GitHub)](https://github.com/mjd507)\n",
    "[![WeChat Channel](https://img.shields.io/badge/Wechat-Daily%20Problem-important?style=social&logo=WeChat)](https://mp.weixin.qq.com/s/p6BglIy8iy0Y3Z_hw3BRTA)\n",
    "\n",
    "![Logo](img/Day78-1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "　　给定一组整数数组`arr`，其中所有数字都出现了两次，仅有额外1个数字只出现了一次。请找到这个数。\n",
    "\n",
    "　　其中，你的解决方案需要限制在$O(n)$时间复杂度和$O(1)$空间复杂度内。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 用例说明\n",
    "\n",
    "```python\n",
    "In[1]: arr = [7, 3, 5, 5, 4, 3, 4, 8, 8]\n",
    "Out[1]: 7\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def findSingle(self, nums: list) -> int:\n",
    "        result = 0\n",
    "        for item in nums:\n",
    "            result = item ^ result\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "print(Solution().findSingle([1, 1, 3, 4, 4, 5, 6, 5, 6]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
